package com.hua.yuan.provider.user;
import android.support.annotation.NonNull;
import com.hua.yuan.base.Constents;
import cm.hua.yuan.common.utils.PreferenceUtils;

/**
 * @Author: richsjeson.
 * @Description: TODO() 用户信息参数
 * @Date:Created in 2018/12/23 1:52 PM.
 * @Modified By:
 */
public class UserProviderImpl implements IUserProvider {

    private User mUser;

    @Override
    public IUserProvider setToken(@NonNull final String pToken) {
        PreferenceUtils.setString(Constents.TOKEN,pToken);
        return this;
    }

    @Override
    public IUserProvider setUserInfo(@NonNull final User pUserInfo) {
        this.mUser=pUserInfo;
        PreferenceUtils.setBoolean(Constents.IS_LOGIN, true);
        return this;
    }

    @Override
    public IUserProvider setMobilePhone(@NonNull final String pMobilePhone) {
        PreferenceUtils.setString(Constents.USER_NAME,pMobilePhone);
        return this;
    }

    @Override
    public IUserProvider setPassword(@NonNull final String pPassword) {
        PreferenceUtils.setString(Constents.USER_PWS,pPassword);
        return this;
    }

    @Override
    public String getToken() {
        return PreferenceUtils.getString(Constents.TOKEN,"");
    }

    @Override
    public User getUser() {
        return mUser;
    }

    @Override
    public boolean getIsLogin() {
        return PreferenceUtils.getBoolean(Constents.IS_LOGIN, false);
    }

    @Override
    public String getMobilePhone() {
        return PreferenceUtils.getString(Constents.USER_NAME, "");
    }

    @Override
    public String getPassword() {
        return PreferenceUtils.getString(Constents.USER_PWS, "");
    }

}
